<?php

$this->widget('ext.Truulo.TruuloModuleSearch', array(
    'model' => $model,
    'grid_id' => $grupo->id . '_grid',
    'id' => 'form_' . $grupo->id,
    'nameInput' => 'input_' . $grupo->id,
    'idList' => 'sel_' . $grupo->id
        )
);

$this->widget('ext.selgridview.BootSelGridView', array(
    'id' => $grupo->id . '_grid',
    'type' => 'striped bordered hover advance',
    "template" => "{items}{summary}{pager}",
    'dataProvider' => $model->activos()->searchByGroup($ids),
    'afterAjaxUpdate' => 'function(id,data){ $(\'span.star-rating > input\').rating(); $(\'div .rating-cancel\').hide(); ratingA();}',
    'selectableRows' => 2,
    'columns' => array(
        array(
            'class' => 'CCheckBoxColumn',
        ),
        array(
            'name' => 'rating',
            'type' => 'raw',
            'value' => '$this->grid->controller->widget("CStarRating", array (
                        "name" => $data->id,
                        "id" => "rating_".$data->id,
                        "value" => $data->rating,
                        "allowEmpty" => false,
                        "maxRating" => 5,
                        "htmlOptions" => array("class"=>"star-rating"),
                        "callback"=>"js:function(){
                            rating($data->id);
                        }"
                    ), true)',
            'htmlOptions' => array('class' => 'hidden-phone'),
            'headerHtmlOptions' => array('style' => 'width:85px;', 'class' => 'hidden-phone'),
            'filter' => false,
            'sortable' => true,
            'header' => '<i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i><i class="icon-star"></i>',
            'visible' => Util::checkAccess(array("action_contacto_rating"))
        ),
        array(
            'name' => 'nombre_completo',
            'value' => 'CHtml::link($data->nombre_completo, Yii::app()->createUrl("crm/contacto/view",array("id"=>$data->id)))',
            'type' => 'raw',
        ),
        array(
            'name' => 'cuenta_id',
            'value' => '$data->cuenta_id?CHtml::link($data->cuenta->nombre, Yii::app()->createUrl("crm/cuenta/view",array("id"=>$data->cuenta_id))):""',
            'type' => 'raw',
        ),
        'cargo',
        array(
            'name' => 'grupo',
            'value' => '!empty($data->grupos) ? $data->gruposToString() : null',
            'type' => 'html'
        ),
        array(
            'name' => 'telefono',
            'value' => '$data->getTelefonoTipo("CONVENCIONAL TRABAJO")'
        ),
        array(
            'name' => 'celular',
            'value' => '$data->getTelefonoTipo("CELULAR")',
        ),
        array(
            'name' => 'owner_id',
            'value' => 'Yii::app()->user->um->loadUserById($data->owner_id)->username',
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{sms} {medioenvio} {llamada} {update} {delete}',
            'buttons' => array(
                'llamada' => array(
                    'label' => '<button class="btn btn-warning"><i class="icon-phone"></i></button>',
                    'options' => array('title' => 'Registrar llamada'),
                    'imageUrl' => false,
                    'url' => '$data->id',
                    'click' => 'function() {crearLlamadaSaliente($(this).attr("href")); return false;}',
                    'visible' => 'Util::checkAccess(array("action_llamada_cargarFormularioLlamadaSaliente"))'
                ),
                'sms' => array(
                    'label' => '<button class="btn btn-success"><i class="icon-comments"></i></button>',
                    'options' => array('title' => 'Enviar SMS'),
                    'imageUrl' => false,
                    'url' => '$data->id',
                    'click' => 'function() {enviarSmsSolo($(this).attr("href")); return false;}',
                    'visible' => 'Util::checkAccess(array("action_sms_cargarFormularioSms"))'
                ),
                /* Botones para envios de Mail sin medio de envio */
//                            'email' => array(
//                                'label' => '<button class="btn btn-inverse"><i class="icon-envelope"></i></button>',
//                                'options' => array('title' => 'Enviar Correo Electrónico'),
//                                'imageUrl' => false,
//                                'url' => '$data->id',
//                                'click' => 'function() {enviarMailSolo($(this).attr("href"),"contacto/admin"); return false;}',
//                                'visible' => 'Util::checkAccess(array("action_mail_cargarFormularioMail"))'
//                            ),
//                            'mandrill' => array(
//                                'label' => '<button class="btn btn-inverse"><i class="icon-envelope"></i></button>',
//                                'options' => array('title' => 'Enviar Correo Electrónico Mandrill'),
//                                'imageUrl' => false,
//                                'url' => '$data->id',
//                                'click' => 'function() {enviarMailMandrillSolo($(this).attr("href"),"contacto/admin"); return false;}',
//                            // 'visible' => 'Util::checkAccess(array("action_mail_cargarFormularioMail"))'
//                            ),
                /*                 * ************************************************* */
                'medioenvio' => array(
                    'label' => '<button class="btn btn-inverse"><i class="icon-envelope"></i></button>',
                    'options' => array('title' => 'Enviar Correo Electrónico'),
                    'imageUrl' => false,
                    'url' => '$data->id',
                    'click' => 'function() {medioEnviarMailSolo($(this).attr("href"),"contacto/admin"); return false;}',
                    'visible' => 'Util::checkAccess(array("action_contacto_ajaxCargarMedioEnvio"))'
                ),
                'update' => array(
                    'label' => '<button class="btn btn-primary"><i class="icon-pencil"></i></button>',
                    'options' => array('title' => 'Actualizar'),
                    'imageUrl' => false,
                    'visible' => 'Util::checkAccess(array("action_contacto_update"))'
                ),
                'delete' => array(
                    'label' => '<button class="btn btn-danger"><i class="icon-trash"></i></button>',
                    'options' => array('title' => 'Eliminar'),
                    'imageUrl' => false,
                    'visible' => 'Util::checkAccess(array("action_contacto_delete"))'
                ),
            ),
            'htmlOptions' => array(
                'width' => '206px'
            )
        ),
    ),
));
?>
